import time

import requests
import json

url = "https://crm.hongsong.info/gateway/api/fjkt-crm-course-ui-interfaces/v2/course/round-page"

payload = json.dumps({
    "liveState": 1,
    "current": 1,
    "pageSize": 100,
    "roundStartTime": "2024-03-15 00:00:00",
    "roundEndTime": "2024-03-15 23:59:59"
})
headers = {
    'authority': 'crm.hongsong.info',
    'istio-v': 'feature-reward-0226',
    'loginsource': 'crm',
    'token': 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJmYW5jaGFvQGhvbmdzb25nLmNsdWIiLCJjcmVhdGVkIjoxNzEwMjEyMjY4NDc5LCJleHAiOjE3MTI4Mzg4Mjh9.-BXfh5nYGCCMtN_dzVmicr2IZI0X9wWeHe3lZX6uFDl6CPu-5jc4LZX3buNxTpe4Jz23A2jg1q6LVEIB0gwKWg',
    'userid': 'null',
    'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
    'content-type': 'application/json'
}

num01 = 0
while True:
    response = requests.request("POST", url, headers=headers, data=payload)

    print(1)
    print(response.text)
    num02 = response.json()['data']['totalCount']
    print(1)
    if num02 != num01:
        print(num02)
        url1 = 'https://open.feishu.cn/open-apis/bot/v2/hook/794a4514-87af-423b-bf17-1e2443a817fd'  # 替换为您的飞书机器人Webhook地址

        headers1 = {
            'Content-Type': 'application/json'
        }
        data1 = {
            "msg_type": "text",
            "content": {
                "text": str(num02)
            }
        }

        response1 = requests.post(url1, headers=headers1, data=json.dumps(data1))

        num01 = num02
    time.sleep(10)
